package com.hz.house.controller;

import com.hz.house.bean.vo.CityTradeInfoWrapperVO;
import com.hz.house.bean.vo.HouseCertHistoryWrapperVO;
import com.hz.house.bean.vo.LocalTradeInfoWrapperVO;
import com.hz.house.common.ResultBean;
import com.hz.house.common.ResultUtil;
import com.hz.house.service.HousePriceTradeInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@Api("房价情报相关接口")
@RestController
@RequestMapping("/api/v2/fjqb")
public class HousePriceInfoController {
    @Autowired
    private HousePriceTradeInfoService infoService;
    @ApiOperation("获取城市商品房交易数据")
    @GetMapping("/listCityTradeInfo")
    public ResultBean<CityTradeInfoWrapperVO> listCityTradeInfo(){
        return ResultUtil.ok(infoService.listCityTradeInfo());
    }

    @ApiOperation("成都市成交实时数据")
    @GetMapping("/listLocalTradeInfo")
    public ResultBean<LocalTradeInfoWrapperVO> listLocalTradeInfo(){
        return ResultUtil.ok(infoService.listLocalTradeInfo());
    }

    @ApiOperation("获取周开盘统计信息")
    @GetMapping("/listWeekOpenInfo")
    public ResultBean<HouseCertHistoryWrapperVO> listWeekOpenInfo(
            @ApiParam("统计日期, 不传获取上一周的统计信息")
            @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
            @RequestParam(value = "date", required = false) Date date){
        return ResultUtil.ok(infoService.listWeekOpenInfo(date));
    }
}
